<?
/**
* <b>Gravy Autoloader</b>
*
* This file is used to autoload PHP classes so you don't have to include() them everywhere (which is a b1@tch).
* It's not recommended to add or edit this code here unless you potentially want to f**k up the Gravy Framework.
*
* php.net: This function searches common directories in your gravy application directory for 
* PHP Class files, eliminiating the need to write include statements for each class file.
*
* @fn __autoload
* @param $class - the class to be loaded
* @return void
*/
function __autoload($class){
	if(file_exists($file=GRAVY_ROOT_DIR.$class.".php")){
		require_once($file);
	}elseif(file_exists($file=GRAVY_ROOT_DIR."classes/".$class.".php")){
		require_once($file);
	}elseif(file_exists($file=GRAVY_ROOT_DIR."classes/renderers/".$class.".php")){
		require_once($file);
	}elseif(file_exists($file=APP_ROOT_DIR."classes/".$class.".php")){
		require_once($file);
	}elseif(file_exists($file=APP_ROOT_DIR."classes/models/".$class.".php")){
		require_once($file);
	}elseif(file_exists($file=APP_ROOT_DIR."config/".$class.".php")){
		require_once($file);
	}elseif(file_exists($file=GRAVY_ROOT_DIR."plugins/".$class.".php")){
		require_once($file);
	}else{
		foreach($GLOBALS["plugins"] as $plugin=>$dir){
			if(file_exists($file=$dir.$class.".php")){
				require_once($file);
			}
		}
	}
}


?>
